<?php include_once("../../../common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once(ROOT_PATH_ . "/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once("../controller/data_list.php");                     // 当前页面的控制器 ?>



<body>

<!--顶部栏-->
<div id="topbar"> <?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?></div>

<!--容器-->
<div id="container" class="<? echo $now_extender ?>">

    <!--侧边栏-->
    <div id="sidebar"><?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?></div>





    <?
    //==============================================================================
    //这里开始才是平常开发需要注重的部分，其余的基本不用理会
    //==============================================================================
    ?>



        <div id="content">

            <!--标题设定-->
            <?php $page_title='添加分类';?>
            <?php include ROOT_PATH_ . '/controller/common/module/mod-page-title.php'; ?>



                <div class="term-detail-box">
                    <ul>
                        <form id="term_detail_form" method="post" class="layui-form"
                              action ="category_add_function.php?<? echo $data['url_parameter'] ?>"
                              enctype="multipart/form-data">


                            <li class="layui-form-item mid">
                                <label class="layui-form-label">人工编号：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" name="ai_mid" size="20" value="">
                                    <em class="explain">(填写您自己设置的编号，人工编号不作排序)</em></div>
                            </li>

                            <li class="layui-form-item name">
                                <label class="layui-form-label">分类名称：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="ai_name" size="20" value="">
        <em class="explain">(<u style="color:red">*必填项目</u>,填写本分类的标题)</em>
    </div>
                            </li>





                            <li class="layui-form-item term"><label class="layui-form-label">所属分类：</label>

								<div class="layui-input-block">

                                <select name="ai_term_id">


                                    <option value="root" selected="selected">当前所属分类:根目录 \</option>
                                    <?
                                    $table_Suffix = $sys_term_table;
                                    $table = $table_Prefix . $table_Suffix;
                                    $sort_by = "nid";
                                    $sort_order = "desc";
                                    ?>

                                    <?php
                                    $query = mysql_query("SELECT COUNT(nid) FROM $table where interm = 'root' and belong ='$sys_belong'");
                                    $term0sum = mysql_result($query, 0);

                                    $result_term0 = mysql_query("select * from $table where interm='root' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");

                                    while($row = mysql_fetch_array($result_term0))
                                    {
                                        $term0_nid[]=$row['nid'];
                                        $term0_name[]=$row['name'];
                                    }

                                    ?>
                                    <? for($i=0;$i<$term0sum;$i++) { ?>
                                        <option value="<?php echo $term0_nid[$i] ?>"> | - <?php echo $term0_name[$i] ?></option>
                                        <?
                                        $query2 = mysql_query("SELECT COUNT(nid) FROM $table where term1 = $term0_nid[$i] && interm = 'term1'  and belong ='$sys_belong'  ");
                                        $term1sum = mysql_result($query2, 0);
                                        if ($_REQUEST ['sortby']) {
                                            $sort_by = $_REQUEST ['sortby'];
                                        }
                                        $result1 = mysql_query("select * from $table where term1 = $term0_nid[$i] && interm = 'term1' and belong ='$sys_belong'  ORDER BY $sort_by ");
                                        while ($row = mysql_fetch_array($result1)) {
                                            {
                                                $term1_nid[$i][] = $row['nid'];
                                                $term1_mid[$i][] = $row['mid'];
                                                $term1_name[$i][] = $row['name'];
                                            }
                                        }
                                        ?>
                                        <?for ($ii = 0; $ii < $term1sum; $ii++) {?>
                                            <option value="<?php echo $term1_nid[$i][$ii] ?>"> |---- <?php echo $term1_name[$i][$ii] ?></option>
                                        <?php } ?>
                                    <?php } ?>


                                </select>
                                    <em class="explain">(选择本分类对应的上级分类，如是一级分类，请选择“根目录”)</em>
                                </div>
                </li>
                            <li  class="layui-form-item introduce">
                                <label class="layui-form-label">分类简介：</label>
                            	<div class="layui-input-block">
                                <textarea name="ai_introduce" class="layui-textarea"  cols="20"></textarea>
                                    <em class="explain">(填写本分类的分类概述文字)</em>
                                </div>
                            </li>

                            <li class="layui-form-item icon"><label class="layui-form-label">ICON：</label><img
                                        src="../images/default-image.jpg" width="150"/><span
                                        class="title-data">(请上传像素<? echo $first_icon_data[0] ?>X<? echo $first_icon_data[1] ?>符合比例的图片,格式为jpeg)</span>
                            </li>
                            <li class="layui-form-item icon"><label class="layui-form-label">上传文件：</label>
                                <div class="layui-input-block"><input type="file" name="icon"
                                                                      onchange="fileChange(this);"/>
                                    <em class="explain">(上传本分类的列表图标)</em></div>
                            </li>
                            <br/>







                            <li class="layui-form-item detail">
                                <label class="layui-form-label">分类详情：</label>
                                <div class="layui-input-block"><textarea name="ai_detail" style="width:800px;height:400px;visibility:hidden;">
                                </textarea>
                                    <em class="explain">(填写本分类前台显示的详细文字介绍，默认留空)</em>
                                </div>
                            </li>



                            <li class="layui-form-item listorder">
                                <label class="layui-form-label">列表排序：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input"  name="ai_listorder" lay-verify="number" value="0">
                                    <em class="explain">(填写本分类在所属前台列表下的列表排序，数字越大，排序越靠前)</em>
                                </div>
                            </li>






                            <li class="layui-form-item publish">
                                <label class="layui-form-label">发布状态：</label>
                                <div class="layui-input-block">
                                    <input name='ai_publish' type='radio' value='1' id="publish_now" title="立即发布"/>
    								<input name='ai_publish' type='radio' value='0' id="publish_later"  checked="checked" title="暂未发布"  />
                                    <em class="explain">(选择立即发布，以上信息才能在前台显示；选择暂未发布，只对以上信息进行保存，不在前台显示)</em>
                                </div>
                            </li>





                            <li class="layui-form-item inputtime"><label class="layui-form-label">输入时间：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="ai_date" name="ai_date" size="20" 
                                           size="20" value="<? echo date("Y-m-d H:i:s") ?>"
                                            class="laydate-icon laydate layui-input">
                                    <em class="explain">(填写录入时间)</em>

                                </div>

                            </li>





                            <div class="function">
                               	<input type="hidden" name="detail_attr" id="detail_attr" />
                                <button class="layui-btn "  type="button" lay-submit lay-filter="formSub">立即提交</button>
                                <input type="reset" class="layui-btn" value="重置"/>
                            </div>
                        </form>
                    </ul>
                </div>
            </div>



        <?
        //==============================================================================
        //这里上面才是平常开发需要注重的部分，下面的基本不用理会，只有底部JS部分需要根据实际情况去加载
        //==============================================================================
        ?>



    </div>
    <!--detail-box end-->


</div>
<!--content端點01-->
<?
//==============================================================================
//这里上面才是平常开发需要注重的部分，下面的基本不用理会，只有底部JS部分需要根据实际情况去加载
//==============================================================================
?>





<br class="clearfloat"/>
<!--container-->
</div>




<!--底部栏-->
<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>


<!--载入删除功能-->
<script type="text/javascript" src="/controller/common/asset/js/deleter.js"></script>


<!--渲染日期需要用到的-->
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#publish_date' //指定元素
            ,type: 'datetime'
        });
    });
</script>

</body>
</html>












